home *** CD-ROM | disk | FTP | other *** search
/ AI Game Programming Wisdom / AIGameProgrammingWisdom.iso / SourceCode / 05 Tactical Issues / 03 vanderSterren / Listing2.cpp < prev   
Encoding:
Text File  |  2001-12-09  |  1.6 KB  |  42 lines

  1. /* Copyright (C) William van der Sterren, 2001. 
  2.  * All rights reserved worldwide.
  3.  *
  4.  * This software is provided "as is" without express or implied
  5.  * warranties. You may freely copy and compile this source into
  6.  * applications you distribute provided that the copyright text
  7.  * below is included in the resulting source code, for example:
  8.  * "Portions Copyright (C) William van der Sterren, 2001"
  9.  */
  10.  
  11. // Algorithms for picking a next position and evaluating each position.
  12.  
  13. // SquadMemberAI::PickNextPosition
  14. for( spot=nearbyspots.begin(); position!=nearbyspots.end(); ++spot ) {
  15.     if( IsClaimedByFellowSquadMember(*spot) )
  16.         continue;
  17.     value = GetManeuverValueForNextPosition(*spot);
  18.  
  19.     if( value > highestvalue ) {
  20.         mostsuitablespot = *spot; 
  21.         highestvalue= value;
  22.     }
  23. }
  24.  
  25. float SquadMemberAI::GetManeuverValueForNextPosition(spot)
  26. {
  27.   return   m_BunchPenalty       * ProjDistToBuddiesAsSeenFromThreat(spot)
  28.          + m_BlockedPenalty     * BlockedLineOfFireBySqdMembers(spot)
  29.          + m_BlockingPenalty    * BlockingLineOfFireOfSqdMembers(spot)
  30.          + m_NeedForCover       * DistanceToNearestFreeCoverSpot(spot)
  31.          + m_NeedForContact     * NumberOfLinesOfSightToBuddies(spot)
  32.          + m_NeedCohesion       * ProperDistanceToBuddies(spot)
  33.          + m_NeedForIntel       * NumberOfLinesOfSightToThreats(spot)
  34.          + m_NeedToAvoidCorpses * DistanceToDeadBuddies(spot)   
  35.          + m_NeedForClosingIn   * MinimumDistanceToThreats(spot)
  36.          // below are non-reactive
  37.          + m_NeedForStrongSpot  * AverageTacticalValueOfSpot(spot)
  38.          + m_FormationPenalty   * DistanceFromFormationSlot(spot);
  39. }
  40.  
  41.  
  42.